package org.yxing.palpalgps.image;

import java.util.concurrent.Future;

import org.yxing.palpalgps.image.ImageLoader.ImageLoaderCallback;

import android.content.Context;

public class ImageRequest {
	
	private static ImageLoader sImageLoader;
	private Future<?> mFuture;
	private Context mContext;
	private String mUrl;
	private ImageLoaderCallback mCallback;
	
	public ImageRequest(Context context, String url, ImageLoaderCallback callback) {
		mContext = context;
		if (sImageLoader == null) {
			sImageLoader = new ImageLoader(mContext);
		}
		mUrl = url;
		mCallback = callback;
	}
	
	public void load() {
		mFuture = sImageLoader.loadImage(mUrl, mCallback);
	}
	
	public void cancel() {
		if (!mFuture.isCancelled()) {
			mFuture.cancel(false);
		}
	}
}
